<!--
 * @Descripttion: 打印按钮
-->

<template>
	<div class="sc-button">
		<el-button type="success" v-auth="auth" :disabled="selectionList.length != 1" @click="print">打印</el-button>
		<!--  打印-->
		<sc-print-template v-if="dialog.print" ref="printDialog" @closed="dialog.print = false"></sc-print-template>
	</div>
</template>

<script>
// import config from "@/config/select";

export default {
	props: {
		selection: {type: Array, default: () => ([])},
		auth: { type: String, default: '' },
	},
	data() {
		return {
			selectionList: this.selection,
			dialog: {
				print: false,
			},
		}
	},
	// 监控data中的数据变化
	watch: {
		'selection'(val) {
			this.selectionList = val
		}
	},
	created() {
		console.log('auth',this.auth)
	},
	methods: {
		/**打印*/
		async print() {
			this.dialog.print = true
			this.$nextTick(() => {
				this.$refs.printDialog.open('edit').getId(this.selectionList[0].id)
			})
		},
	}
}
</script>

<style scoped>
.sc-button {
	margin-left: 12px;
}
</style>
